/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mii.ejb.session;

import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import mii.dao.EngineerDAO;
import mii.dao.impl.EngineerDAOImpl;
import mii.ejb.entity.Complain;
import mii.ejb.entity.Engineer;

/**
 *
 * @author TEKNISI
 */
@Stateless
public class EngineerSessionBean implements EngineerSessionBeanLocal {
    @PersistenceContext(unitName = "helpdesk-ika-ejbPU")
    private EntityManager em;

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")

    @Override
    public void saveEngineer(String kodeEng, String nameEng, String solusiEng, String tindakanEng, Date startEng, Date finishEng) {
        EngineerDAO engdao = new EngineerDAOImpl(em);
        Engineer eng = new Engineer();
        eng.setKodeEng(kodeEng);
        eng.setNameEng(nameEng);
        eng.setSolusiEng(solusiEng);
        eng.setTindakanEng(tindakanEng);
        eng.setStartEng(startEng);
        eng.setFinishEng(finishEng);
        try {
            engdao.insert(eng);
        } catch (Exception ex) {
            Logger.getLogger(EngineerSessionBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    
    
    @Override
    public List<Engineer> getAllEngineer() {
        EngineerDAO engdao = new EngineerDAOImpl(em);
        try {
            return engdao.getAll();
        } catch (Exception ex) {
            Logger.getLogger(EngineerSessionBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        return null;
               
    }

}
